<!--网站导航.搜索条1-->
<script src="/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="/uploadify/uploadify.css">
<form class="bs-docs-example form-horizontal" action="<?php echo WEB_DOMAIN; ?>/app/add" id="register_submit" method="post" enctype="application/x-www-form-urlencoded">
    <input type="hidden" name="add[id]" value="<?php echo $authUser[admin_id];?>">
    <div class="control-group info">        
        <div>
            <label for="inputError" class="control-label">所属开发者：</label>
            <input name="add[username]" type="text" id="username" value="<?php echo $add["username"];?>" autocomplete="off"> <span class="help-inline">输入提示选择对应开发者</span><br>
            <label for="inputError" class="control-label"></label>
            <select name="add[uid]" onchange="userChange();" id="usernames" multiple="multiple" class="typeahead dropdown-menu span2" style="position:relative;display: none;">
                <option value="<?echo $add["uid"];?>" selected="selected"><?php echo $add["username"];?></optin>
            </select><br>
        </div>
        <div>
            <label for="inputError" class="control-label">关 联 人 员：</label>
            <input type="text" name="add[assname]" id="assname" value="<?php echo $add["assname"];?>" autocomplete="off"><span class="help-inline">输入提示选择对应关联人员</span><br>
            <label for="inputError" class="control-label"></label>
            <select name="add[assid]" onchange="assChange();" id="assnames" multiple="multiple" class="typeahead dropdown-menu span2" style="position:relative;display: none;">
            <option value="<?php echo $add["assid"];?>" selected="selected"><?php echo $add["assname"];?></optin>
            </select>
        </div>
        <p><hr><span class="btn">应用信息</span> <b>设置广告位&上传应用</b>  <span style=" color: red;"><?php echo $err_msg;?></span><hr></p>
    </div>
    <div class="control-group info">
        <label for="inputError" class="control-label">应用名称：</label>
        <div class="controls">
            <input type="text" class="input-xxlarge" name="add[name]" id="addname" value="<?php echo $add["name"] ?>">
        </div>
    </div>
    <div class="control-group info">
        <label for="input" class="control-label">应用版本号：</label>
        <div class="controls">
            <input type="text" class="input-xlarge" name="add[version]" id="version" value="<?php echo $add["version"] ?>">
        </div>
    </div>
    <div class="control-group info">
        <label for="inputError" class="control-label">应用平台：</label>
        <div class="controls">
            <li class="form-inline">
                <label><input type="radio"  name="add[platformid]" id="version" value="1" checked>iphone</label>
                <label><input type="radio"  name="add[platformid]" id="version" value="2">ipad</label>
                <label><input type="radio"  name="add[platformid]" id="version" value="3">Android</label>
                <label><input type="radio"  name="add[platformid]" id="version" value="4">iphone&ipad</label>
            </li>
        </div>
    </div>
    <div class="control-group success">
        <label for="inputSuccess" class="control-label">应用分类：</label>
        <div class="controls">
            <select name="add[classid]" class="span2">
                <option value="0">选择分类</option>
                <?php
                 if (isset($appClass)) {
                    foreach ($appClass as $key => $val) {
                        if($val["id"]==$add["classid"]){
                            echo '<option value="' . $val["id"] . '" selected="selected">' . $val["title"] . '</option>'; 
                        }else{
                            echo '<option value="' . $val["id"] . '">' . $val["title"] . '</option>';
                        }
                    }
                }
                ?>
            </select>
            <span class="help-inline"></span>
        </div>
    </div>
    <div class="control-group success">
        <label for="inputSuccess" class="control-label">应用连接：</label>
        <div class="controls">
            <input type="text" id="appurl" class="input-xxlarge" name="add[appurl]" value="<?php echo $add["appurl"] ?>">
            <span class="help-inline">请填写您的APP在应用市场上的下载地址</span>
        </div>
    </div>
    <div class="control-group success">
        <label for="inputSuccess" class="control-label">应用图标：</label>
        <div class="controls">
            <div id="queue"></div>
            <input type="hidden" id="uploadFileName" name="add[appimg]" value="<?php echo $add["appimg"] ?>">
            <input type="file" id="file_upload"  multiple="true">
            <span class="help-inline" id="uperr">
                <?php if (!empty($add["appimg"])) { ?>
                    <img src="/uploads/img<?php echo $add["appimg"] ?>" style="height: 72px;" />
                <?php } ?>
                请上传尺寸不小于 72x72 , 大小不超过1M, 格式为 png, jpg, jpeg 的图标</span>
        </div>
    </div>
    <div class="control-group success">
        <label for="inputSuccess" class="control-label">应用介绍：</label>
        <div class="controls">
            <textarea name="add[introduce]"><?php echo $add["introduce"] ?></textarea>
            <span class="help-inline"></span>
        </div>
    </div>
    <button class="btn btn-large btn-block" type="submit">保存并进入下一步</button>
</form>
<script type="text/javascript">
<?php $timestamp = time(); ?>
    var webChange;
    $(function() {     
        adproject.uploadify($('#file_upload'), '<?= session_id(); ?>', 'img', '', ucallback);
        function ucallback(file, data, response) {
            $("#file_upload").hide();
            data = eval('('+data+')');
            if( 'success' == data.res){
                $("#uploadFileName").val(data.extra.filepath);
                $("#uperr").html("<img src='" + data.extra.rootpath + data.extra.filepath +"' style='height: 72px;' />");              
            }else{
                $("#uperr").html("上传失败");
                $("#file_upload").show();
            } 
        }       
    });
    $('#username').on('input',function(){
        var senddata={};
        var username=$('#username').val();
        senddata["username"]=username;
        $.ajax({
            type: "POST",
            url: "/app/showWebuser",
            data: senddata,
            success: function(msg){
                if(msg == 0){
                    $('#usernames').html("<option value='0'>" + username + "-账号不存在</option>");
                }else{
                    $('#usernames').html(msg);
                    $('#usernames').show();
                }			
            }
        });
    });
    $('#assname').on('input',function(){
        var senddata={};
        var username=$('#assname').val();
        senddata["assname"]=username;
        $.ajax({
            type: "POST",
            url: "/app/showSysuser",
            data: senddata,
            success: function(msg){
                if(msg == 0){
                    $('#assnames').html("<option value='0'>" + username + "-不存在</option>");
                }else{
                    $('#assnames').html(msg);
                    $('#assnames').show();
                }			
            }
        });
    });
    function userChange(){
        var _txt=$("#usernames").find("option:selected").text();
        $('#username').val(_txt);
        $('#usernames').hide();
    }
    function assChange(){
        var _txt=$("#assnames").find("option:selected").text();
        $('#assname').val(_txt);
        $('#assnames').hide();
    }
    function dump_obj(myObject) {  
        var s = "";  
        for (var property in myObject) {  
            s = s + "\n "+property +": " + myObject[property] ;  
        }  
        alert(s);  
    }
</script>